package com.stu.entity.permission;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.stu.entity.base.BaseEntity;

@Entity
@Table(name = "PERMISSION_MENU")
public class PermissionMenu extends BaseEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;


	private String cname;// 名称
	private String url; // 请求路径
	private String description; // 描述
	private PermissionMenu parentMenu;// 父菜单
	private Integer orderNo; // 排序号
	private PermissionMenuRoot root; // 菜单组
	private String icon;// 图标

	private List<PermissionMenu> menus = new ArrayList<PermissionMenu>();

	public PermissionMenu() {
		super();
	}

	public PermissionMenu(String uuid) {
		super(uuid);
	}

	public PermissionMenu(String cname, String url, String description, PermissionMenu parentMenu, Integer orderNo, PermissionMenuRoot root, String icon, List<PermissionMenu> menus) {
		super();
		this.cname = cname;
		this.url = url;
		this.description = description;
		this.parentMenu = parentMenu;
		this.orderNo = orderNo;
		this.root = root;
		this.icon = icon;
		this.menus = menus;
	}

	@Column(name = "cname", length = 50)
	public String getCname() {
		return cname;
	}

	public void setCname(String cname) {
		this.cname = cname;
	}

	@Column(name = "url", length = 255)
	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	@Column(name = "description", length = 255)
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@ManyToOne(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY)
	@JoinColumn(name = "pid")
	public PermissionMenu getParentMenu() {
		return parentMenu;
	}

	public void setParentMenu(PermissionMenu parentMenu) {
		this.parentMenu = parentMenu;
	}

	@Column(name = "orderno")
	public Integer getOrderNo() {
		return orderNo;
	}

	public void setOrderNo(Integer orderNo) {
		this.orderNo = orderNo;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "root")
	public PermissionMenuRoot getRoot() {
		return root;
	}

	public void setRoot(PermissionMenuRoot root) {
		this.root = root;
	}

	@Column(name = "icon", length = 255)
	public String getIcon() {
		return icon;
	}

	public void setIcon(String icon) {
		this.icon = icon;
	}

	@OneToMany(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY)
	@JoinColumn(name = "pid")
	/*@Where(clause = "USE_FLAG='Y'")*/
	public List<PermissionMenu> getMenus() {
		return menus;
	}

	public void setMenus(List<PermissionMenu> menus) {
		this.menus = menus;
	}
}
